<?php

namespace app\admin\model\shop;

use think\Model;


class Order extends Model
{

    

    

    // 表名
    protected $name = 'order';
    
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = false;

    // 定义时间戳字段名
    protected $createTime = false;
    protected $updateTime = false;
    protected $deleteTime = false;

    // 追加属性
    protected $append = [
        'status_text'
    ];
    

    
    public function getStatusList()
    {
        return ['2' => __('Status 2'), '3' => __('Status 3'), '4' => __('Status 4'),
            '5' => __('Status 5'), '6' => __('Status 6'), '7' => __('Status 7'),
            '9' => __('Status 9'),'13' => __('Status 13')];
    }

    public function getUserStatusList()
    {
        return ['0' => __('Status 0'),'1' => __('Status 1'),'2' => __('Status 2'), '3' => __('Status 3'), '4' => __('Status 4'),
            '5' => __('Status 5'), '6' => __('Status 6'), '7' => __('Status 7'),'8' => __('Status 8'), '9' => __('Status 9'),
            '10' => __('Status 10'),'11' => __('Status 11'),'12' => __('Status 12'),'13' => __('Status 13')];
    }

    public function getShopStatusList()
    {
        return ['2' => __('Status 2'), '3' => __('Status 3'), '4' => __('Status 4'),
            '5' => __('Status 5'), '6' => __('Status 6'), '7' => __('Status 7'),
            '9' => __('Status 9'),'13' => __('Status 13')];
    }

    public function getRefundStatusList()
    {
        return ['1' => '退款中', '2' => '退款成功', '3' => '退款失败'];
    }


    public function getStatusTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['status']) ? $data['status'] : '');
        $list = $this->getStatusList();
        return isset($list[$value]) ? $list[$value] : '';
    }




    public function user()
    {
        return $this->belongsTo('app\admin\model\User', 'uid', 'id', [], 'LEFT')->setEagerlyType(0);
    }


    public function shop()
    {
        return $this->belongsTo('app\admin\model\Shop', 'shop_id', 'id', [], 'LEFT')->setEagerlyType(0);
    }
}
